This article mainly introduces the formSerialize, fieldSerialize, fieldValue, resetForm, clearForm, and clearFields application of the jQueryForm form submission plug-in. For more information, see
I. Other APIs of jQuery Form
1. formSerialize
Serialize a form into a query string. This method returns a string, for example, name1 = value1 name2 = value2.Whether a serial call is allowed: No, this method returns a string.
Example:
var queryString = $('
empty array, or it will contain at least one value.Whether a serial call is possible: No, this method returns an array.Example:
Get the value of the password input
var value = $ (' #myFormId:p assword '). Fieldvalue ();
Alert (' The password is: ' + value[0]);
4. Resetform
Resets the form to its original state by calling methods on the inner dom of the form element.Can be called by serial: YesExample:
$ (' #myFormId '). Resetform ();
5.
/*** Clear the content in the specified form and set the parameter to the id of the target form * Note: When you use the JqueryEasyUI pop-up window to input new content, each time the previous input history * data is opened, the common method is to empty each input component: $ (# name ). val (). In this way, * when many input components exist
/*** Clears the content of the specified form. The parameter is the id of the target form.* Note: When you use the Jquery EasyUI pop-up window to input ne
JQuery form pluginJQuery. form
This is a jQuery plug-in that fully supports forms and supports file upload. It includes the following methods:
-AjaxForm-AjaxSubmit-FormToArray-FormSerialize-FieldSerialize-FieldValue-ClearForm-ClearFields-ResetForm
Sample Code:
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->// Wait for the Dom to be loaded
$ (Document). Ready (function (){
// Bind 'myform' and provide
serialize) a form into a query string. This method returns a string in the following format: Name1=value1name2=value2.
No
$ ("#formid"). Formserialize ();
Fieldserialize
Serializes (or serialize) the field elements of a form into a single query string. This is handy when only a subset of the form fields need to be serialized (or serializable). Returns a string in the following format: Name=value1name2=value2.
No
$ ("#formid. Specialfields"). Fieldserialize ();
following methods.** @param formid The ID of the form form that will empty the content*/function Resetcontent (formId) {var clearform = document.getElementById (formId);if (null! = ClearForm typeof (ClearForm)! = "undefined") {Clearform.reset ();}}2. Refresh the DataGrid list (for the DataGrid in the JQuery Easy UI)/*** Refresh the DataGrid list (for the DataGr
that matches the inserted array. From version 0.91, this method will always return data in the form of arrays. If the element value is determined to be invalid, the array is empty; otherwise, it contains one or more element values.Chainable: No. This method returns an array.
Instance:// Obtain the password input valueVaR value = $ ('# myformid: password'). fieldvalue ();Alert ('the password is: '+ value [0]);
Resetform
Restore the form to its initial state by calling the original DOM method of
. This is convenient when only some form fields need to be serialized (or serialized. This method returns a string in the following format: name1 = value1 name2 = value2.Chainable: No. This method returns a string.
Instance:
VaR querystring = $ ('# myformid. specialfields'). fieldserialize ();
Fieldvalue ()
Returns the value of the form element that matches the inserted array. From version 0.91, this method will always return data in the form of arrays. If the element value is determine
. General Usage:
$(document).ready(function() { var options = { target: ‘#output1‘, // target element(s) to be updated with server response beforeSubmit: showRequest, // pre-submit callback success: showResponse // post-submit callback // other available options: //url: url // override for form‘s ‘action‘ attribute //type: type // ‘get‘ or ‘post‘, override for form‘s ‘method‘ attribute //data
= {increase: "++", decrease :"--"}
Var operation = "increase ";
Operations [operation] // "++ ";
Operations ["multiply"] = "*";//"*"
Operations ["multiply"] = "*"; added a key-value pair to the operations object.
7.2 object circular access: for-in
Var obj = {name: "Pete", age: 15 };
For (key in obj ){
Alert ("key is" + [key] + ", value is" + obj [key]);
}
7.3 any object, regardless of its attributes and values, is set to true by default.
7.4 Prototype attribute of the object
Using fn (Prototype
returns a string in the following format: Name1=value1name2=value2.
No
$ ("#formid"). Formserialize ();
Fieldserialize
Serializes (or serialize) the field elements of a form into a single query string. This is handy when only a subset of the form fields need to be serialized (or serializable). Returns a string in the following format: Name=value1name2=value2.
No
$ ("#formid. Specialfields"). Fieldserialize ();
Fieldvalue
Returns the va
();
Fieldserialize
Serializes (or serialize) the field elements of a form into a single query string. This is handy when only a subset of the form fields need to be serialized (or serializable). Returns a string in the following format: Name=value1name2=value2.
No
$ ("#formid. Specialfields"). Fieldserialize ();
Fieldvalue
Returns the value of the form element that matches the inserted array. The method returns data in the form of an array. If the
method returns a string in the following format: Name1=value1name2=value2.
No
$ ("#formid"). Formserialize ();
Fieldserialize
Serializes (or serialize) the field elements of a form into a single query string. This is handy when only a subset of the form fields need to be serialized (or serializable). Returns a string in the following format: Name=value1name2=value2.
No
$ ("#formid. Specialfields"). Fieldserialize ();
Fieldvalue
Returns t
serializable). Returns a string in the following format: Name=value1name2=value2.
No
$ ("#formid. Specialfields"). Fieldserialize ();
Fieldvalue
Returns the value of the form element that matches the inserted array. The method returns data in the form of an array. If the element value is determined to be invalid, the array is empty.
No
$ ("#formid:p assword"). Fieldvalue ();
Resetform
Restores the form to its original state.
No
'). Fieldserialize ();
Fieldvalue
Returns the form element values that match the inserted array. From version 0.91, the method will always return data as an array. If the element value is determined to be invalid, the array is empty, otherwise it will contain one or more element values.
can link (chainable): cannot, this method returns an array.
Instance:
Code:
Copy Code code as follows:
Get Password Input value
var value = $ (' #myFormId:p assword '). Fieldvalue ();
Alert (
objects through Array access)
Var operations = {increase: "++", decrease :"--"}
Var operation = "increase ";
Operations [operation] // "++ ";
Operations ["multiply"] = "*";//"*"
Operations ["multiply"] = "*"; added a key-value pair to the operations object.
7.2 object circular access: for-in
Var obj = {name: "Pete", age: 15 };
For (key in obj ){
Alert ("key is" + [key] + ", value is" + obj [key]);
}
7.3 any object, regardless of its attributes and values, is set to true by default.
7.4 Prototyp
string. This is handy when only a subset of the form fields need to be serialized (or serializable). Returns a string in the following format: Name=value1name2=value2.
No
$ ("#formid. Specialfields"). Fieldserialize ();
Fieldvalue
Returns the value of the form element that matches the inserted array. The method returns data in the form of an array. If the element value is determined to be invalid, the array is empty.
No
$ ("#formid:p assword"). Fieldvalue
following format: Name1=value1name2=value2.
No
$ ("#formid"). Formserialize ();
Fieldserialize
Serializes (or serialize) the field elements of a form into a single query string. This is handy when only a subset of the form fields need to be serialized (or serializable). Returns a string in the following format: Name=value1name2=value2.
No
$ ("#formid. Specialfields"). Fieldserialize ();
Fieldvalue
Returns the value of the form element th
into a single query string. This is handy when only a subset of the form fields need to be serialized (or serializable). Returns a string in the following format: Name=value1name2=value2.
No
$ ("#formid. Specialfields"). Fieldserialize ();
Fieldvalue
Returns the value of the form element that matches the inserted array. The method returns data in the form of an array. If the element value is determined to be invalid, the array is empty.
No
$ ("#formid:p as
var querystring = $ (' #myFormId. Specialfields '). Fieldserialize ();
Fieldvalue
Returns the form element values that match the inserted array. From version 0.91, the method will always return data as an array. If the element value is determined to be invalid, the array is empty, otherwise it will contain one or more element values.can link (chainable): cannot, this method returns an array.
Instance:
The code is as follows
Copy Code
Get Pass
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.